<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<s:set name="status_name" value="%{@com.japp.tools.common.SelectVal@ctStatus(c.c_status)}"></s:set>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>客户更新</title>
<s:include value="/app_common/common.jsp"></s:include>
<!-- 表单验证start -->
<script src="<s:property value='webctx'/>/libs/js/form/validationRule.js" type="text/javascript"></script>
<script src="<s:property value='webctx'/>/libs/js/form/validation.js" type="text/javascript"></script>
<!-- 表单验证end -->
<!-- 树组件start -->
<script type="text/javascript" src="<s:property value='webctx'/>/libs/js/tree/ztree/ztree.js"></script>
<link type="text/css" rel="stylesheet" href="<s:property value='webctx'/>/libs/js/tree/ztree/ztree.css"></link>
<!-- 树组件end -->
<!-- 日期选择框start -->
<script type="text/javascript" src="<s:property value='webctx'/>/libs/js/form/datePicker/WdatePicker.js"></script>
<!-- 日期选择框end -->
<!-- 用户选择start -->
<script type="text/javascript" src="<s:property value='webctx'/>/app_common/userPopup/queryUser.js"></script>
<!-- 用户选择end -->
<style type="text/css">
input[type="radio"],label{
	cursor: pointer;
}
</style>
</head>
<body>
<form id="form1" name="form1" action="" target="frmright">
<%--客户状态名称 --%>
<s:hidden name="status_name" id="status_name"></s:hidden>
<%--当前提交操作人 --%>
<s:hidden name="c.c_submit_uname" value="%{#session.u_name}"></s:hidden>
<%--当前提交操作人编码 --%>
<s:hidden name="c.c_submit_ucode" value="%{#session.u_code}"></s:hidden>
<%--当前营业部 --%>
<s:hidden name="c.c_suoshu_yyb" value="南京营业部"></s:hidden>
<s:if test="c.c_code!=null&&c.c_code!=''">
	<%--所属人编码 --%>
	<s:hidden name="c.c_suoshu_ucode" id="user_code"></s:hidden>
	<%--所属人名称 --%>
	<s:hidden name="c.c_suoshu_uname" id="user_name"></s:hidden>
	<%--所属分部--%>
	<s:hidden name="c.c_suoshu_dpcode"></s:hidden>
	<%--所属分部名称--%>
	<s:hidden name="c.c_suoshu_dpname"></s:hidden>
</s:if>
<s:else>
	<%--所属人编码 --%>
	<s:hidden name="c.c_suoshu_ucode" id="user_code" value="%{#session.u_code}"></s:hidden>
	<%--所属人名称 --%>
	<s:hidden name="c.c_suoshu_uname" id="user_name" value="%{#session.u_name}"></s:hidden>
	<%--所属分部--%>
	<s:hidden name="c.c_suoshu_dpcode" value="%{#session.userltdcode}"></s:hidden>
	<%--所属分部名称--%>
	<s:hidden name="c.c_suoshu_dpname" value="%{#session.userltdname}"></s:hidden>
</s:else>
<div class="box2" panelWidth="750" panelTitle="<s:property value='status_name'/>管理">
	<table class="tableStyle" style="line-height: 30px" formMode="transparent">
		<s:if test="c.c_code!=null&&c.c_code!=''">
			<s:hidden id="c_code" name="c.c_code" value="%{c.c_code}"></s:hidden>
			<s:hidden name="c.c_id"></s:hidden>
			<s:hidden name="c.c_num_date"></s:hidden>
			<tr>
				<td class="ali01">建档编号：</td>
				<td colspan="2"><s:property value="c.c_code"/></td>
				<td class="ali01">建档日期：</td>
				<td colspan="2"><s:property value="c.c_num_date"/></td>
			</tr>
			<tr>
				<td class="ali01">经纪人编号：</td>
				<td colspan="2"><s:property value="c.c_suoshu_ucode"/></td>
				<td class="ali01">经纪人名称：</td>
				<td colspan="2"><s:property value="c.c_suoshu_uname"/></td>
			</tr>
		</s:if>
		<tr>
			<td class="ali01">客户名称：</td>
			<td>
				<input type="text" name="c.c_name" value="<s:property value='c.c_name'/>" class="validate[required,custom[chinese],length[0,20]]">
				<span class="star">*</span>
			</td>
			<td class="ali01">客户分类：</td>
			<td>
				<select name="c.c_type" id="c_type" onchange="checkType(this)" selectedValue="<s:property value='c.c_type'/>" prompt="请选择" data='<s:property value="map.sel_3"/>' class="validate[required]" ></select>
				<span class="star">*</span>
			</td>
			<td class="ali01">客户来源：</td>
			<td>
				<select name="c.c_source" selectedValue="<s:property value='c.c_source'/>" prompt="请选择" data='<s:property value="map.sel_4"/>' class="validate[required]" ></select>
				<span class="star">*</span>
			</td>
		</tr>
		<tr>
			<td class="ali01">所属地区：</td>
			<td>
				<select name="c.c_area" selectedValue="<s:property value='c.c_area'/>" prompt="请选择" data='<s:property value="map.sel_2"/>' class="validate[required]" ></select>
				<span class="star">*</span>
			</td>
			<td class="ali01">所属行业：</td>
			<td>
				<select name="c.c_hangye" selectedValue="<s:property value='c.c_hangye'/>" prompt="请选择" data='<s:property value="map.sel_1"/>' class="validate[required]" ></select>
				<span class="star">*</span>
			</td>
			<td class="ali01">关联品种：</td>
			<td>
				<input type="text" re name="c.c_strain" value="<s:property value='c.c_strain'/>" class="validate[required]" >
				<span class="star">*</span>
			</td>
		</tr>
		<tr>
			<td class="ali01">联系人：</td>
			<td>
				<input type="text" name="c.c_lianxiren" value="<s:property value='c.c_lianxiren'/>" class="validate[required]" >
				<span class="star">*</span>
			</td>
			<td class="ali01">客户部门：</td>
			<td>
				<select name="c.c_dp" selectedValue="<s:property value='c.c_dp'/>" prompt="请选择" data='<s:property value="map.sel_6"/>' class="validate[required]" ></select>
				<span class="star">*</span>
			</td>
			<td class="ali01">客户职务：</td>
			<td>
				<select name="c.c_zhiwu" selectedValue="<s:property value='c.c_zhiwu'/>" prompt="请选择" data='<s:property value="map.sel_7"/>' class="validate[required]" ></select>
				<span class="star">*</span>
			</td>
		</tr>
		<tr>
		<td class="ali01">客户性别：</td>
			<td>
				<select name="c.c_sex" selectedValue="<s:property value='c.c_sex'/>" prompt="请选择" data='{"list":[{"key":"男","value":"1"},{"key":"女","value":"2"}]}' class="validate[required]" ></select>
				<span class="star">*</span>
			</td>
			<td class="ali01">客户年龄：</td>
			<td>
				<input type="text" name="c.c_cs_date" value="<s:property value='c.c_cs_date'/>" class="validate[required,custom[onlyNumber],length[0,3]]" watermark="请输入数字" maxlength="3">
				<span class="star">*</span>
			</td>
			<td class="ali01">客户籍贯：</td>
			<td>
				<select name="c.c_from" selectedValue="<s:property value='c.c_from'/>" prompt="请选择" data='<s:property value="map.sel_8"/>' class="validate[required]" ></select>
				<span class="star">*</span>
			</td>
		</tr>
		<tr>
			<td class="ali01">手机：</td>
			<td>
				<input type="text" name="c.c_mobile_hone" value="<s:property value='c.c_mobile_hone'/>" maxlength="11" class="validate[required,custom[mobilephone]]" >
				<span class="star">*</span>
			</td>
			<td class="ali01">办公电话：</td>
			<td>
				<%--class="validate[required,custom[telephone]]" 暂时不必填 --%>
				<input type="text" name="c.c_phone" value="<s:property value='c.c_phone'/>" maxlength="15" >
			</td>
			<td class="ali01">传真：</td>
			<td>
				<%--class="validate[required,custom[telephone]]" 暂时不必填 --%>
				<input type="text" name="c.c_chuanzhen" value="<s:property value='c.c_chuanzhen'/>" maxlength="15">
			</td>
		</tr>
		<tr>
			<td class="ali01">QQ：</td>
			<td>
				<%--class="validate[required,custom[qq]]" 暂时不必填 --%>
				<input type="text" name="c.c_qq" value="<s:property value='c.c_qq'/>" maxlength="13" >
			</td>
			<td class="ali01">电子邮件：</td>
			<td>
				<%--class="validate[required,custom[email]]" 暂时不必填 --%>
				<input type="text" name="c.c_email" value="<s:property value='c.c_email'/>" class="validate[required,custom[email]]">
			</td>
			<td class="ali01">MSN：</td>
			<td>
				<%--class="validate[required]" 暂时不必填 --%>
				<input type="text" name="c.c_msn" value="<s:property value='c.c_msn'/>"  >
			</td>
		</tr>
		<tr id="jg">
			<td class="ali01">客户网址：</td>
			<td>
				<input type="text" name="c.c_http" value="<s:property value='c.c_http'/>"  class="validate[required]">
				<span class="star">*</span>
			</td>
			<td class="ali01">法人代表：</td>
			<td>
				<input type="text" name="c.c_faren" value="<s:property value='c.c_faren'/>" class="validate[required]">
				<span class="star">*</span>
			</td>
			<td class="ali01">注册资本：</td>
			<td>
				<input type="text" name="c.c_ziben" id="c_ziben" value="<s:property value='c.c_ziben'/>" class="validate[required,custom[onlyNumberWide]]" maxlength="10">
				<span class="star">*</span>
			</td>
		</tr>
		<tr>
			<td class="ali01">客户地址：</td>
			<td colspan="3">
				<input type="text" name="c.c_address" value="<s:property value='c.c_address'/>" style="width: 320px" class="validate[required]" >
				<span class="star">*</span>
			</td>
			<td class="ali01">邮编：</td>
			<td>
				<%--class="validate[required,custom[zipcode]]" 暂时不必填 --%>
				<input type="text" name="c.c_youbian" value="<s:property value='c.c_youbian'/>">
			</td>
		</tr>
		<tr>
			<td class="ali01">期货认知程度：</td>
			<td>
				<select name="c.c_renzhichengdu" selectedValue="<s:property value='c.c_renzhichengdu'/>" prompt="请选择" data='<s:property value="map.sel_9"/>' class="validate[required]" ></select>
				<span class="star">*</span>
			</td>
			<td class="ali01">预估投资潜力：</td>
			<td>
				<select name="c.c_yuguqianli" selectedValue="<s:property value='c.c_yuguqianli'/>" prompt="请选择" data='<s:property value="map.sel_10"/>' class="validate[required]" ></select>
				<span class="star">*</span>
			</td>
			<td class="ali01">价值评估：</td>
			<td>
				<select name="c.c_jiazhi" selectedValue="<s:property value='c.c_jiazhi'/>" prompt="请选择" data='<s:property value="map.sel_11"/>' class="validate[required]" ></select>
				<span class="star">*</span>
			</td>
		</tr>
		<tr>
			<td class="ali01">客户提醒：</td>
			<td colspan="5">
				<input type="text" name="c.c_kehutixing" value="<s:property value='c.c_kehutixing'/>" style="width: 380px" watermark="无提醒"  maxlength="100">
			</td>
		</tr>
		<tr>
			<td class="ali01">初始策略：</td>
			<td colspan="5">
				<textarea name="c.c_initcelue" style="width: 500px"><s:property value='c.c_initcelue'/></textarea>
			</td>
		</tr>
		<tr>
			<td colspan="8">
				<s:if test="c.c_status==1">
					<s:if test="c.c_id==0">
						<s:radio name="c.c_status" value="%{c.c_status}" list="#{'1':'潜在客户'}"></s:radio>
					</s:if>
					<s:else>
						<s:radio name="c.c_status" value="%{c.c_status}" list="#{'1':'潜在客户','2':'转为重点潜在客户','3':'转为正式客户'}"></s:radio>
					</s:else>
				</s:if>
				<s:elseif test="c.c_status==2">
					<s:radio name="c.c_status" value="%{c.c_status}" list="#{'2':'重点潜在客户','3':'转为正式客户'}"></s:radio>
				</s:elseif>
				<s:elseif test="c.c_status==3">
					<s:radio name="c.c_status" value="%{c.c_status}" list="#{'3':'服务客户','4':'转为重点服务客户'}"></s:radio>
				</s:elseif>
				<s:elseif test="c.c_status==4">
					<s:radio name="c.c_status" value="%{c.c_status}" list="#{'4':'重点服务客户'}"></s:radio>
				</s:elseif>
			</td>
		</tr>
	</table>
</div>
<div style="width: 750px" align="right">
<input type="button" value="返回" onclick="back()">
<input type="button" value='添加<s:property value="c.c_status<=2?'计划':'服务'"/>' onclick="insertJF()">
<input type="button" value="提 交" onclick="checkSubmit()">
</div>

	<div id="jfdiv_" style="width: 750px">
	<s:iterator value="list_ci" status="stat">
		<div id="jfdiv_0">
		<!-- div class="ali03"><a>删除</a></div> -->
		<fieldset>
			<s:hidden name="list_ci1[%{#stat.index}].ci_id" value="%{ci_id}"></s:hidden>
			<s:hidden name="list_ci1[%{#stat.index}].ci_stauts" value="%{ci_stauts}"></s:hidden>
			<legend>第<s:property value='#stat.count'/>次<s:property value="ci_stauts==1?'计划':'服务'"/></legend>
			<table class="tableStyle" count="tableSize" id="jf_<s:property value='#stat.index'/>" style="line-height: 30px" formMode="transparent">
				<tr>
					<td class="ali01"><s:property value="ci_stauts==1?'计划':'服务'"/>时间：</td>
					<td>
						<input type="text" name="list_ci1[<s:property value='#stat.index'/>].ci_date" value="<s:property value='ci_date'/>" style="cursor: pointer;" class="date validate[required]">
						<span class="star">*</span>
					</td>
					<td class="ali01"><s:property value="ci_stauts==1?'计划':'服务'"/>方式：</td>
					<td>
						<input type="text" name="list_ci1[<s:property value='#stat.index'/>].ci_fangshi" value="<s:property value='ci_fangshi'/>" class="validate[required]" >
						<span class="star">*</span>
					</td>
					<td class="ali01"><s:property value="ci_stauts==1?'计划':'服务'"/>营销工具：</td>
					<td>
						<input type="text" name="list_ci1[<s:property value='#stat.index'/>].ci_tools" value="<s:property value='ci_tools'/>" class="validate[required]" maxlength="10">
						<span class="star">*</span>
					</td>
				</tr>
				<s:if test="ci_stauts==1">
				<tr>
					<td  class="ali01"><s:property value="ci_stauts==1?'计划':'服务'"/>进度目标：</td>
					<td colspan="5">
						<s:radio name="list_ci1[%{#stat.index}].ci_mubiao" value="%{ci_mubiao}" list="#{'1':'明确具体服务内容','2':'认可本人及公司','3':'形成合作意向','4':'明商定开户交易时间'}"></s:radio>
						<span class="star">*</span>
					</td>
				</tr>
				<tr>
					<td  class="ali01"><s:property value="ci_stauts==1?'计划':'服务'"/>策略：</td>
					<td colspan="5">
						<textarea style="width: 540px;height: 80px;" name="list_ci1[<s:property value='#stat.index'/>].ci_celue">
							<s:property value='ci_celue'/>
						</textarea>
					</td>
				</tr>
				</s:if>
				<s:else>
					<input type="hidden" name="list_ci1[<s:property value='#stat.index'/>].ci_mubiao" value="0">
					<input type="hidden" name="list_ci1[<s:property value='#stat.index'/>].ci_celue"value="0">
				</s:else>
				<tr>
					<td class="ali01">跟踪结论：</td>
					<td colspan="5" class="ali01">
					<textarea style="width: 540px;height: 40px;" name="list_ci1[<s:property value='#stat.index'/>].ci_jielun">
						<s:property value='ci_jielun'/>
					</textarea>
				</td>
			</tr>
		</table>
	</fieldset>
	</div>
	</s:iterator>
</div>
<s:if test="(c.c_status==1||c.c_status==2) && c.c_id!=0">
<div style="width: 750px">
<fieldset>
	<legend>最终结论</legend>
	<div align="center" style="text-align: center;">
		<s:if test="c.c_status == 1">
			<s:radio list="#{1:'计划开户',2:'放弃',3:'继续跟踪',4:'交由他人跟踪' }" value="%{c.c_type_status}"  name="c.c_type_status" onclick="checkRadio(this)"></s:radio>
			<a href="javascript:;" style="display: none;" id="cn" onclick="queryUserAll()">选择继续跟踪用户</a>
		</s:if>
		<s:elseif test="c.c_status == 2">
			<s:radio list="#{1:'计划开户',2:'放弃',3:'继续跟踪',4:'交由他人跟踪' }" value="%{c.c_type_status}"  name="c.c_type_status" onclick="checkRadio(this)"></s:radio>
			<a href="javascript:;" style="display: none;" id="cn" onclick="queryUserAll()">选择继续跟踪用户</a>
		</s:elseif>
	</div>
</fieldset>
</div>
</s:if>
<div style="height: 10px"></div>

</form>
</body>
<script type="text/javascript">
var status =$('input[name="c.c_status"]:checked').val();
var status_name = $('#status_name').val();
var user_name = $('#user_name').val();
var user_code = $('#user_code').val();
var type_status = '<s:property value="c.c_type_status"/>';
$('textarea').each(function(){
	$(this).text($.trim($(this).text()));
});
if(type_status=="4"){
	$('#cn').show();
}
function checkRadio(obj){
	if($(obj).val()==4){
		$('#cn').show();
	}else{
		$('#cn').hide();
		if(user_code!=null&&user_code!=''){
			$('#user_code').val(user_code);
			$('#user_name').val(user_name);
		}
	}
}
//alert($('table[count="tableSize"]').length);
function checkSubmit(){
	if($('#c_type').val()==1){
		$('#jg input').val(' ');
		$('#c_ziben').val('0.00');
	}
	var valid =$("#form1").validationEngine({returnIsValid: true});
	if(valid){
		var c_code = $('#c_code').val();
		var url = '';
		if(c_code!=null&c_code!=''){
			url = webctx+'/ct/ct_updateCustomer.action';
		}else{
			url = webctx+'/ct/ct_insertCustomer.action';
		}
		top.Dialog.confirm("验证通过，确认提交更新?",function(){
			showProgressBar();
			document.form1.action = url;
			document.form1.submit();
		});
	}
}
/**
 * 添加服务或者计划
 */
function insertJF(){
	var len = $('table[count="tableSize"]').length;
	if(len==0){
		$('#box2').show();
	}
	//alert(len);
	var $tableView = $(getTableView(len));
	$('#jfdiv_').append($tableView);
	$('#jf_'+len+',#jf_'+len+' td *').each(function(){
		$(this).render();
	});
}
function delTableView(obj){
	$(obj).parent().parent().remove();
}
function getTableView(index){
var str='<div id="jfdiv_'+index+'"><div class="ali03"><a onclick="delTableView(this)">删除</a></div>'+
	'<fieldset>'+
		'<legend>第'+(index+1)+'次'+(status<=2?"计划":"服务")+'</legend>'+
		'<input type="hidden" value="'+(index+1)+'" name="list_ci['+index+'].ci_cishu">'+
		'<input type="hidden" value="'+(status<=2?1:2)+'" name="list_ci['+index+'].ci_stauts">'+
		'<table class="tableStyle" count="tableSize" id="jf_'+index+'" style="line-height: 30px" formMode="transparent">'+
			'<tr>'+
				'<td class="ali01">'+(status<=2?"计划":"服务")+'时间：</td>'+
				'<td>'+
					'<input type="text" name="list_ci['+index+'].ci_date" style="cursor: pointer;" class="date validate[required]">'+
					'<span class="star">*</span>'+
				'</td>'+
				'<td class="ali01">'+(status<=2?"计划":"服务")+'方式：</td>'+
				'<td>'+
					'<input type="text" name="list_ci['+index+'].ci_fangshi" class="validate[required]" >'+
					'<span class="star">*</span>'+
				'</td>'+
				'<td class="ali01">'+(status<=2?"计划":"服务")+'营销工具：</td>'+
				'<td>'+
					'<input type="text" name="list_ci['+index+'].ci_tools" class="validate[required]" maxlength="10">'+
					'<span class="star">*</span>'+
				'</td>'+
			'</tr>';
			//策略
			if(status<=2){
				str+='<tr>'+
				'<td  class="ali01">'+(status<=2?"计划":"服务")+'进度目标：</td>'+
				'<td colspan="5">'+
					'<input type="radio" name="list_ci['+index+'].ci_mubiao" checked="checked" id="list_ci_'+index+'__ci_mubiao1" value="1"/><label for="list_ci_'+index+'__ci_mubiao1">明确具体服务内容</label>'+
					'<input type="radio" name="list_ci['+index+'].ci_mubiao" id="list_ci_'+index+'__ci_mubiao2" value="2"/><label for="list_ci_'+index+'__ci_mubiao2">认可本人及公司</label>'+
					'<input type="radio" name="list_ci['+index+'].ci_mubiao" id="list_ci_'+index+'__ci_mubiao3" value="3"/><label for="list_ci_'+index+'__ci_mubiao3">形成合作意向</label>'+
					'<input type="radio" name="list_ci['+index+'].ci_mubiao" id="list_ci_'+index+'__ci_mubiao4" value="4"/><label for="list_ci_'+index+'__ci_mubiao4">明商定开户交易时间</label>'+
					'<span class="star">*</span>'+
				'</td>'+
				'</tr>'+
				'<tr>'+
					'<td  class="ali01">'+(status<=2?"计划":"服务")+'策略：</td>'+
					'<td colspan="5">'+
						'<textarea style="width: 540px;height: 80px;" name="list_ci['+index+'].ci_celue"></textarea>'+
					'</td>'+
				'</tr>';
			}else{
				str+='<input type="hidden" name="list_ci['+index+'].ci_mubiao" value="0"><input type="hidden" name="list_ci['+index+'].ci_celue" value="0">';
			}
			str+='<tr>'+
				'<td class="ali01">'+(status<=2?"计划":"服务")+'结论：</td>'+
				'<td colspan="5" class="ali01">'+
					'<textarea style="width: 540px;height: 40px;" name="list_ci['+index+'].ci_jielun"></textarea>'+
				'</td>'+
			'</tr>'+
		'</table>'+
	'</fieldset></div>';
	return str;
}
function back(){
	top.Dialog.confirm("确认返回?",function(){
		showProgressBar();
		window.location = webctx+'/ct/ct_queryCustomer.action?c.c_status='+status;
	});
}
/**
 * 客户类型
 */
function checkType(obj){
	var obj = $(obj);
	var jg = $('#jg');
	if(obj.val()==1){
		jg.hide();
		$('#jg input').val('');
	}else{
		jg.show();
		$('#jg input').val('');
	}
}
$(function(){
	var jg = "<s:property value='c.c_type'/>";
	var result = '<s:property value="result"/>';
	if(jg==1){
		$('#jg').hide();
	}
	if(result!=null&&result!=''){
		top.Dialog.alert(result);
	}
});
</script>
</html>